package com.example.dhhyc.demos.strategy.strategy3;

import java.util.HashMap;
import java.util.Map;

/**
 * Describe :
 * question :类被加载static方法就执行
 *
 * @author BaiShanshan
 * @date 2024/5/3 10:16
 */

public class ReceiptHandleStrategyFactory {
    private static Map<String, ReceiptHandleStrategy> map = new HashMap<String, ReceiptHandleStrategy>();

    private static void init() {
        map.put("MT2101回执", new MT2101ReceiptHandleStrategy());
        map.put("MT4101回执", new MT4101ReceiptHandleStrategy());
        map.put("MT8104回执", new MT8104ReceiptHandleStrategy());
        map.put("MT1101回执", new MT1101ReceiptHandleStrategy());
    }

    public static ReceiptHandleStrategy getInvokeHandler(String type) {
        if (map.isEmpty()) {
            init();
        }
        return map.get(type);
    }
}
